﻿$.fn.extend({
			showdiag:function(diagwidth,diagheight,intopacity,srcurl){
				
				var enabled='<div id="messagebox_enabled" style="background-color: #000000;width:100%;height:'+$(document).height()+'px;position:absolute;top:0px;left:0px;z-index:10000;"></div>';
				var diawindow='<div class="plunbox" id="diawindow"><div class="inbox"><div class="inbox-tt"><a href="javascript:"><img src="/images/close.jpg" alt="关闭" id="closediag" /></a></div><div style="height:'+(diagheight-50)+'px;padding:10px 10px 0;"><iframe src="'+srcurl+'" style="height:100%; width:100%;" scrolling="no" frameborder="0"></iframe></div><div class="clear"></div></div></div>';
					if(!$("#diawindow").length>0)
					{
					$("body").append(diawindow);
					}
					else
					{
						$("#diawindow").show();
					}
					if(!$("#messagebox_enabled").length>0)
					{
						$("body").append(enabled);
					}
					else
					{
						$("#messagebox_enabled").show();
					}
					 var css={}
				  if(window.navigator.userAgent.indexOf('MSIE')>=1)
					{
						css.filter= 'progid:DXImageTransform.Microsoft.Alpha(opacity='+intopacity*100+')';
					}
					else
					{
						css.opacity= intopacity;
					}
					$("#messagebox_enabled").css(css);
					
					var w,h,de;
					de = document.documentElement;
					w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
					h = self.innerHeight || (de&&de.clientHeight)|| document.body.clientHeight;							
					var cssdia={top:eval(h/2-diagheight/2+$(document).scrollTop())+"px",left:eval(w/2-diagwidth/2)+"px",width:diagwidth+"px",height:diagheight+"px"};
					$(window).scroll(function(){
											 var diagtop = h/2-(diagheight/2)+eval($(document).scrollTop());
											 var diagleft = w/2-(diagwidth/2)+eval($(document).scrollLeft());
											 $("#diawindow").css({"top" : diagtop,"left":diagleft });
					});				
					
					$("#diawindow").css(cssdia);
					$("#closediag").click(function(){
					$("#diawindow").remove();
					$("#messagebox_enabled").remove();
					});
				}
			})
